(function(){
	'use strict';

    var app = angular.module('myApp.login-module');
	
    app.factory( 'SessionService', [ '$window', function ( $window ) {
    	var session = {};
    	
    	session.create = function( user ) {
    		this.user = user;
    	    $window.sessionStorage["user"] = JSON.stringify( { user : user } );
    	};
    	
    	session.destroy = function(){
    		this.user = null;
    	    delete $window.sessionStorage["user"];
    	};
    	
    	return session;
    } ] );
    
})();